package com.shengzai.mapreduce.text2;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class OutPutDriver {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        Job job = Job.getInstance(new Configuration());
        job.setJobName("output");
        job.setJarByClass(OutPutDriver.class);

        job.setMapperClass(OutputMapper.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(NullWritable.class);

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(NullWritable.class);

        /**
         * 如果需要自定义输出类，那么就需要再Driver中进行设置
         *
          */

        job.setOutputFormatClass(MyOutputFormat.class);

        FileInputFormat.addInputPath(job,new Path("hadoop_code/src/data/StudentJoin/part-r-00000"));
        FileOutputFormat.setOutputPath(job,new Path("hadoop_code/src/data/text3"));

        job.waitForCompletion(true);

    }
}
